<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<!-- IE 浏览作用 兼容模式打开页面。 chrome=1 开启 chrome 支持，适用多个核的浏览器。 -->
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<meta charset="UTF-8">
	<title>JEHC微服务平台..</title>
	<link rel="icon" type="image/ico" href="../deng/images/icons/system.png" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<meta name="format-detection" content="telephone=no">
	<meta name="renderer" content="webkit">
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	
	<link href="../deng/source/plugins/newAdmin/vendors/base/flaticon.css" rel="stylesheet" type="text/css" />
    <link href="../deng/source/plugins/newAdmin/bootstrap/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css" />
    <link href="../deng/source/plugins/newAdmin/bootstrap/4.0.0/css/icons.css" rel="stylesheet" type="text/css" />
    <link href="../deng/source/plugins/newAdmin/bootstrap/4.0.0/css/style.css" rel="stylesheet" type="text/css" />
    
	<link rel="stylesheet" type="text/css" href="../deng/source/css/loginicon/iconfont.css" />
	<script src="../deng/source/css/loginicon/iconfont.js" type="text/javascript" charset="utf-8"></script>
	<!-- 基础插件样式开始 -->
	<link href="../deng/source/plugins/newAdmin/bootstrap/4.0.0/css/style.css" rel="stylesheet" type="text/css" />
    <link href="../deng/source/plugins/newAdmin/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
	<!-- 基础插件样式结束 -->
	<!-- 自定义主题样式开始 -->
	<link href="../deng/source/css/login.css" rel="stylesheet" type="text/css" />
	<!-- 自定义主题样式结束 -->
	<!-- 基础插件开始 -->
	<script src="../deng/source/plugins/newAdmin/vendors/base/jquery.min.js" type="text/javascript"></script>
    <script src="../deng/source/plugins/newAdmin/bootstrap/4.0.0/js/bootstrap.min.js" type="text/javascript"></script>
	<!-- 基础插件结束 -->
	<!-- 提示插件开始 -->
	<link href="../deng/source/plugins/newAdmin/bootstrap/bootstrap-toastr/toastr.min.css" rel="stylesheet" type="text/css" />
    <script src="../deng/source/plugins/newAdmin/bootstrap/bootstrap-toastr/toastr.min.js" type="text/javascript"></script>
    <script src="../deng/source/plugins/newAdmin/bootstrap/bootbox.js" type="text/javascript"></script>
	<!-- 提示插件结束 -->
	<!-- bootstrap验证框架开始 -->
    <link rel="stylesheet" type="text/css" href="../deng/source/plugins/newAdmin/bootstrap/bootstrap-validate/bootstrapValidator.css" />
    <script src="../deng/source/plugins/newAdmin/bootstrap/bootstrap-validate/bootstrapValidator.js" type="text/javascript"></script>
    <!-- bootstrap验证框架结束 -->
    <!-- 公共模块包含上传控件，共同JS封装 -->
    <script type="text/javascript" src="../deng/source/js/base.js"></script>
    <script type="text/javascript" src="../deng/source/js/boot.min.js"></script>
	<style type="text/css">
		.titlee {
			width: 100%;
			margin: auto;
			padding-top: 18%;
			padding-left: 4%;
		}
		.input-icon>i {
		    position: absolute;
		    margin-top: 12px;
		}
		.bv-form .help-block {
		    color: red;
		}    
	</style>
</head>
	<body>
		<div class="big-bg">
			<div class="bg">
				<div class="describtion">
					<h2>J E H C 开 源 业 务管 理 平 台 </h2>
					<p>微服务版本</p>
					<p>BETA CLOUD V1.0</p>
					<p>DISTRIBUTION OPERATION AND MAAINTENANCE</p>
					<p>MANAGEMENT PLATFORM</p>
				</div>
				<div class="titlee">
					<!-- <img src="../deng/images/login-new/title.png" style="width: 50%;" alt="" /> -->
				</div>
				<div class="contain">
					<div class="login"></div>
					<p class="title">JEHC开源平台</p>
					<div class="line"></div>
					<form id="loginForm" method="post">
						<div class="form-group common">
							<div class="input-icon">
								<i class="flaticon-user-ok"></i>
								<input class="form-control" type="text" placeholder="请输入用户名" name="account" id="userName" autocomplete="off" />
							</div>
						</div>
						<div class="form-group common">
							<div class="input-icon">
								<i class="flaticon-lock"></i>
								<input class="form-control" type="password" placeholder="请输入密码" name="password" id="password" autocomplete="off" />
							</div>
						</div>
						<div class="row" style="padding:0 50px!important">
							<div class="col-sm-6" style="padding-right: 0;">
								<div class="form-group common-li">
									<div class="input-icon">
										<i class="flaticon-logout" style="font-size: 28px;"></i>
										<input class="form-control" type="text" placeholder="请输入验证码" name="validateCode" id="validateCode" />
									</div>
								</div>
							</div>
							<div class="col-sm-3">
								<img src="" id="safecode" width="180" onclick="clickYZM()" />
								</br>
								<a href="javascript:clickYZM()">换一张</a><br><br>
							</div>
						</div>
						<div class="form-group form-login">
							<input type="button" id="loginBtn" class="btn" onclick="login()" value="登录">
						</div>
					</form>
				</div>
			</div>
		</div>
	</body>

	<script type="text/javascript">
		clickYZM();
		function callFocus() {
			var userName = $('#userName').val();
			var password = $('#password').val();
			var validateCode = $('#validateCode').val();
			if(userName == null || userName == '') {
				return $('#userName')[0].focus();
			}
			if(password == null || password == '') {
				return $('#password')[0].focus();
			}
			if(validateCode == null || validateCode == '') {
				return $('#validateCode')[0].focus();
			}
		}
		$(document).ready(function() {
			if(getnavigator() == 7 || getnavigator() == 8 || getnavigator() == 9 || getnavigator() == 6 || getnavigator() == 0) {
				document.write("平台支持IE10及以上浏览器或谷歌，火狐，360等浏览器");
				return;
			}
			$('#myModal').modal({
				backdrop: 'static',
				keyboard: false
			});
			if(getCookie('readme') == 'readme') {
				$("[name='readme']").attr("checked", 'true');
				$('#userName').val(getCookie('XTUSERNAMECOOKIE'));
				$('#password').val(getCookie('XTUSERPASSWORDCOOKIE'));
			}
		});

		//刷新验证码
		function clickYZM() {
			document.getElementById('safecode').src = rest_url_prefix_xt+ "/verify?date="+new Date().getTime();
		}

		$('#loginForm').bootstrapValidator({
			message: '此值不是有效的',
			feedbackIcons: {},
			fields: {
				userName: {
					validators: {
						notEmpty: {
							message: '用户账号不能为空'
						},
						stringLength: {
							min: 1,
							max: 30,
							message: '用户账号字符长度不能超过30个'
						}
					}
				},
				password: {
					validators: {
						notEmpty: {
							message: '密码不能为空'
						},
						stringLength: {
							min: 1,
							max: 20,
							message: '密码字符长度不能超过20个'
						}
					}
				},
				validateCode: {
					validators: {
						notEmpty: {
							message: '验证码不能为空'
						},
						stringLength: {
							min: 6,
							max: 6,
							message: '验证码只能为6个字符'
						}
					}
				}
			}
		});

		$(function() {
			document.onkeydown = function(e) {
				var ev = document.all ? window.event : e;
				if(ev.keyCode == 13) {
					login();
				}
			}
		});
		//提交登录form
		function login() {
			callFocus();
			var bootform = $('#loginForm');
			if(typeof(bootform) == "undefined" || null == bootform || '' == bootform) {
				window.parent.toastrBoot(4, "未能获取到form对象!");
				return;
			}
			//验证
			var boostrapValidator = bootform.data('bootstrapValidator');
			boostrapValidator.validate();
			//验证有效开启发送异步请求
			if(boostrapValidator.isValid()) {
				$.fn.serializeObject = function(){
	                var o = {};
	                var a = this.serializeArray();
	                $.each(a, function() {
	                    if (o[this.name] !== undefined) {
	                        if (!o[this.name].push) {
	                            o[this.name] = [o[this.name]];
	                        }
	                        o[this.name].push(this.value || '');
	                    } else {
	                        o[this.name] = this.value || '';
	                    }
	                });
	                return o;
	            };
				$("#loginBtn").attr("disabled", true);
				$("#loginBtn").val("正在登录中......");
				$.ajax({
					url:rest_url_prefix_xt + '/login',
					type:'POST', //PUT DELETE POST
					xhrFields:{withCredentials:true},
					contentType:"application/json;charset=utf-8",
					data:JSON.stringify(bootform.serializeObject()),
					success: function(result) {
						call(result);
					},
					error: function() {
						clickYZM();
						$("#loginBtn").val("登录");
						$("#loginBtn").attr("disabled", false);
					}
				})
			} else {
				//window.parent.toastrBoot(4,"存在不合法的字段!");
			}
		}

		function call(result) {
			try {
				var obj = result;
				if(obj.success == false) {
					clickYZM();
					window.parent.toastrBoot(4, obj.message);
					$("#loginBtn").val("登录");
					$("#loginBtn").attr("disabled", false);
				} else {
					clearCookie('readme');
					clearCookie('XTUSERNAMECOOKIE');
					clearCookie('XTUSERPASSWORDCOOKIE');
					if($('#readme').is(':checked')) {
						if(null == getCookie('readme') || '' == getCookie('readme')) {
							setCookie('readme', 'readme', 240);
							setCookie('XTUSERNAMECOOKIE', $('#userName').val(), 240);
							setCookie('XTUSERPASSWORDCOOKIE', $('#password').val(), 240);
						}
					}
					$("#loginBtn").val("身份认证成功，开始进入平台......");
					window.parent.toastrBoot(3, "身份认证成功，开始进入平台......");
					window.location.href = base_html_redirect + "/pc/xt-view/index.html";
				}
			} catch(e) {
				$("#loginBtn").val("登录");
				$("#loginBtn").attr("disabled", false);
			}
		}

		document.onreadystatechange = pagecomplete;

		function pagecomplete() {
			if(document.readyState == "complete") {
				setTimeout(function() {
					callFocus();
				}, 500);
			}
		}
	</script>

</html>